<?php

declare(strict_types=1);

namespace app\model\develop;

use owns\interface\OwnsModelInteface;

class ApplyMapModel extends OwnsModelInteface
{
    protected $name = 'develop_apply_map';

    protected $field = [];

    /**
     * 查询条件
     * @param object $query
     * @param array $param
     */
    public function scopeCustom(object $query, array $param)
    {
        //位置：1首页
        if ($location = $param['location'] ?? '') {
            $query->where('location', $location);
        }
        //标题
        if ($title = $param['title'] ?? '') {
            $query->whereLike('title', '%' . trim($title) . '%');
        }
        //跳转： 0不跳转 1页面 2指定链接
        $jumpType = $param['jump_type'] ?? '';
        if (is_numeric($jumpType)) {
            $query->where('jump_type', $jumpType);
        }
        //状态：0隐藏 1显示
        $status = $param['status'] ?? '';
        if (is_numeric($status)) {
            $query->where('status', $status);
        }
    }
}
